package com.lds.employment.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.lds.employment.domain.EmploymentAssistance;
import com.lds.employment.service.IEmploymentAssistanceService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 就业帮扶预约Controller
 * 
 * @author ruoyi
 * @date 2024-01-05
 */
@RestController
@RequestMapping("/assistance")
public class EmploymentAssistanceController extends BaseController
{
    @Autowired
    private IEmploymentAssistanceService employmentAssistanceService;

    @GetMapping("/all")
    public TableDataInfo all()
    {
        startPage();
        List<EmploymentAssistance> list = employmentAssistanceService.all();
        return getDataTable(list);
    }

    /**
     * 查询就业帮扶预约列表
     */
    @RequiresPermissions("employment:assistance:list")
    @GetMapping("/list")
    public TableDataInfo list(EmploymentAssistance employmentAssistance)
    {
        startPage();
        List<EmploymentAssistance> list = employmentAssistanceService.selectEmploymentAssistanceList(employmentAssistance);
        return getDataTable(list);
    }

    /**
     * 导出就业帮扶预约列表
     */
    @RequiresPermissions("employment:assistance:export")
    @Log(title = "就业帮扶预约", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmploymentAssistance employmentAssistance)
    {
        List<EmploymentAssistance> list = employmentAssistanceService.selectEmploymentAssistanceList(employmentAssistance);
        ExcelUtil<EmploymentAssistance> util = new ExcelUtil<EmploymentAssistance>(EmploymentAssistance.class);
        util.exportExcel(response, list, "就业帮扶预约数据");
    }

    /**
     * 获取就业帮扶预约详细信息
     */
    @RequiresPermissions("employment:assistance:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(employmentAssistanceService.selectEmploymentAssistanceById(id));
    }

    /**
     * 新增就业帮扶预约
     */
    @RequiresPermissions("employment:assistance:add")
    @Log(title = "就业帮扶预约", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmploymentAssistance employmentAssistance)
    {
        return toAjax(employmentAssistanceService.insertEmploymentAssistance(employmentAssistance));
    }

    /**
     * 修改就业帮扶预约
     */
    @RequiresPermissions("employment:assistance:edit")
    @Log(title = "就业帮扶预约", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmploymentAssistance employmentAssistance)
    {
        return toAjax(employmentAssistanceService.updateEmploymentAssistance(employmentAssistance));
    }

    /**
     * 删除就业帮扶预约
     */
    @RequiresPermissions("employment:assistance:remove")
    @Log(title = "就业帮扶预约", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(employmentAssistanceService.deleteEmploymentAssistanceByIds(ids));
    }
}
